{% extends "layout.html" %}

{% block title %}脚本区{% endblock %}

{% block css %}{% endblock %}

{% block cardbody %}

<div class="layui-form">

    <div class="layui-form-item">
        <div class="layui-input-group">
            <div class="layui-input-split layui-input-prefix">
                帖子ID
            </div>
            <input type="text" placeholder="请输入您的帖子ID" class="layui-input">
            <div class="layui-input-suffix">
                <button id="Start" class="layui-btn layui-btn-primary" lay-submit lay-filter="demo-submit">开始批量点赞</button>
            </div>
        </div>
    </div>

</div>
{% endblock %}

{% block js %}
<script>
    var layer = layui.layer
    document.querySelector("#Start").addEventListener('click', () => {
        var loadIndex = layer.msg('加载中', {
        icon: 16,
        shade: 0.5,
        title: "稍等一会...",
        content: "正在批量点赞中...",
        anim: 6,
        time:0

      });;
        let PostsID = document.querySelector('.layui-input').value;
        // 向服务器发送
        axios({
            url: "/Batchlike/",
            method: "POST",
            headers: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            data: {
                "PostsID": PostsID
            }
        }).then(res => {
            console.log("响应成功: ", res);
            layer.msg("完成")
            layer.close(loadIndex);
        }).catch(error => {
            console.error("响应失败: ", error);
            layer.close(loadIndex);
        });

    })
   
</script>

{% endblock %}